const webpackMerge = require('webpack-merge');
const webpack = require('webpack');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const baseWebpackConfig = require('./base.config.js');

var webpackConfig = webpackMerge(baseWebpackConfig, {
    //正式发布需要改成压缩模式
    // mode: 'production',
    // devtool: 'source-map',  
    mode: 'development',
    devtool: 'inline-source-map',
    optimization: {
        minimizer: [
            new UglifyJsPlugin({
                uglifyOptions: {
                    //正式发布需要去除console
                    // compress: {
                    //    drop_debugger: true, //debugger
                    //    drop_console: true,// console
                    //    pure_funcs:['console.log'] // 移除console
                    // },
                },
                cache: true, 
                parallel: true ,
                sourceMap: true 
            }),
            new OptimizeCSSAssetsPlugin()
        ],
    },
    plugins: [
        new webpack.HashedModuleIdsPlugin(),
        new ExtractTextWebpackPlugin({
                filename: '[name].[hash:8].css',
                allChunks: true
        }),
    ]
});

module.exports = webpackConfig;

